import {
  getList as getMesSalesOrderList,
  getDeliveryMethodList as getMesSalesOrderDeliveryMethodList,
  getFactoryCodeList as getMesSalesOrderFactoryCodeList,
} from "@/api/order/mesSalesOrder";

export const mesSalesOrderDialog = {
  data() {
    return {
      mesSalesOrderDialogVisible: false, //表格弹框隐藏显示
      getMesSalesOrderList, // 获取弹框数据接口
      hasMesSalesOrderFooter: true, // 是否需要底部按钮默认true
      mesSalesOrderSearchDialog: {
        inline: true,
        formDesc: {
          salesOrderCode: {
            type: "input",
            layout: 8,
            label: $i18n.t('ele-dialog-table.salesOrderCode'),
          },
          customerCode: {
            type: "input",
            layout: 8,
            label: $i18n.t('ele-dialog-table.customerCode'),
          },
          customerName: {
            type: "input",
            layout: 8,
            label: $i18n.t('common.customerName'),
          },
          deliveryMethod: {
            type: "select",
            layout: 8,
            label: $i18n.t('ele-dialog-table.deliveryMethod'),
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getMesSalesOrderDeliveryMethodList();
              return list.data.result;
            },
          },
          deliveryAddress: {
            type: "input",
            layout: 8,
            label: $i18n.t('ele-dialog-table.deliveryAddress'),
          },
          customerOrderCode: {
            type: "input",
            layout: 8,
            label: $i18n.t('ele-dialog-table.customerOrderCode'),
          },
          planDeliveryDate: {
            type: "daterange",
            layout: 16,
            label: $i18n.t('common.planDeliveryDate'),
            attrs: {
              valueFormat: "yyyy-MM-dd",
              searchArrKey: ["planDeliveryDateMin", "planDeliveryDateMax"],
            },
          },
        },
      },
      mesSalesOrderDialogColumn: [
        {
          type: "selection",
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60
        },
        {
          prop: "salesOrderCode",
          label: $i18n.t("mesSalesOrder.salesOrderCode"),
          width: 180,
        },
        {
          prop: "customerCode",
          label: $i18n.t("mesSalesOrder.customerCode"),
          width: 180,
        },
        {
          prop: "customerName",
          label: $i18n.t("mesSalesOrder.customerName"),
          width: 180,
        },
        {
          prop: "deliveryMethod",
          label: $i18n.t("mesSalesOrder.deliveryMethod"),
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getMesSalesOrderDeliveryMethodList();
            return list.data.result;
          },
        },
        {
          prop: "deliveryAddress",
          label: $i18n.t("mesSalesOrder.deliveryAddress"),
          width: 180,
        },
        {
          prop: "customerOrderCode",
          label: $i18n.t("mesSalesOrder.customerOrderCode"),
          width: 180,
        },
        {
          prop: "planDeliveryDate",
          label: $i18n.t("mesSalesOrder.planDeliveryDate"),
          width: 180,
        },
        {
          prop: "factoryCode",
          label: $i18n.t("mesSalesOrder.factoryCode"),
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getMesSalesOrderFactoryCodeList();
            return list.data.result;
          },
        },
        {
          prop: "remark",
          label: $i18n.t("mesSalesOrder.remark"),
          width: 180,
          render: (h, { row }) => {
            let data = row.remark == undefined ? "" : row.remark;
            let str = data.length > 10 ? data.substring(0, 10) + "..." : data;
            return (
              <el-tooltip
                class="item"
                effect="dark"
                content={data}
                placement="top"
              >
                <span>{str}</span>
              </el-tooltip>
            );
          },
        },
        {
          prop: "createByName",
          label: $i18n.t("common.createByName"),
          width: 150,
        },
        {
          prop: "createTime",
          label: $i18n.t("common.createTime"),
          width: 150,
        },
        {
          prop: "updateByName",
          label: $i18n.t("common.updateByName"),
          width: 150,
        },
        {
          prop: "updateTime",
          label: $i18n.t("common.updateTime"),
          width: 150,
        },
      ],
    };
  },
};
